package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TRYSTUDENT;
import com.ruoyi.system.service.ITRYSTUDENTService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 试听生管理Controller
 * 
 * @author ruoyi
 * @date 2021-11-08
 */
@Controller
@RequestMapping("/system/TRYSTUDENT")
public class TRYSTUDENTController extends BaseController
{
    private String prefix = "system/TRYSTUDENT";

    @Autowired
    private ITRYSTUDENTService tRYSTUDENTService;

    @RequiresPermissions("system:TRYSTUDENT:view")
    @GetMapping()
    public String TRYSTUDENT()
    {
        return prefix + "/TRYSTUDENT";
    }

    /**
     * 查询试听生管理列表
     */
    @RequiresPermissions("system:TRYSTUDENT:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TRYSTUDENT tRYSTUDENT)
    {
        startPage();
        List<TRYSTUDENT> list = tRYSTUDENTService.selectTRYSTUDENTList(tRYSTUDENT);
        return getDataTable(list);
    }

    /**
     * 导出试听生管理列表
     */
    @RequiresPermissions("system:TRYSTUDENT:export")
    @Log(title = "试听生管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TRYSTUDENT tRYSTUDENT)
    {
        List<TRYSTUDENT> list = tRYSTUDENTService.selectTRYSTUDENTList(tRYSTUDENT);
        ExcelUtil<TRYSTUDENT> util = new ExcelUtil<TRYSTUDENT>(TRYSTUDENT.class);
        return util.exportExcel(list, "试听生管理数据");
    }

    /**
     * 新增试听生管理
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存试听生管理
     */
    @RequiresPermissions("system:TRYSTUDENT:add")
    @Log(title = "试听生管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TRYSTUDENT tRYSTUDENT)
    {
        return toAjax(tRYSTUDENTService.insertTRYSTUDENT(tRYSTUDENT));
    }

    /**
     * 修改试听生管理
     */
    @GetMapping("/edit/{tryId}")
    public String edit(@PathVariable("tryId") String tryId, ModelMap mmap)
    {
        TRYSTUDENT tRYSTUDENT = tRYSTUDENTService.selectTRYSTUDENTByTryId(tryId);
        mmap.put("tRYSTUDENT", tRYSTUDENT);
        return prefix + "/edit";
    }

    /**
     * 修改保存试听生管理
     */
    @RequiresPermissions("system:TRYSTUDENT:edit")
    @Log(title = "试听生管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TRYSTUDENT tRYSTUDENT)
    {
        return toAjax(tRYSTUDENTService.updateTRYSTUDENT(tRYSTUDENT));
    }

    /**
     * 删除试听生管理
     */
    @RequiresPermissions("system:TRYSTUDENT:remove")
    @Log(title = "试听生管理", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tRYSTUDENTService.deleteTRYSTUDENTByTryIds(ids));
    }
}
